Product : ISaGRAF V3 - DOS Target

Date    : 24-Febuary-1997

File    : Huge.Problem encountered if you compile with huge memory model.htm

Subject : Problem encountered if you compile with huge memory model

Keywords: DOS target - Huge memory model - 64K limit

____________________________________________________________________

Question:

My application exceeds 64K byte.

Is it possible to compile all ISaGRAF DOS KERNEL source files with

a huge memory model in order to overpass this limitation ?

Answer:

Some customers have already done this modification. (ICS Triplex ISaGRAF Inc does not

guarantee it works, because it has not been tested by ICS Triplex ISaGRAF Inc).

The information we have about this modification is that there are

at least 2 possible sources of problems:

A- The jump instruction inside an ISaGRAF application:

to make it work in huge model:

.a pointer casting has to be changed

.an arithmetic formula has to be changed too

B- Some procedures called during initialization (in IDK system

layer) have to be changed

C- With Microsoft compiler V.1.52, a command line that can be

used in batch files to compile with huge memory model is

the following:

cl /nologo /D DOS /c /Alhu /W3 /I DEFS /I USER /FoRELS\ %1

A- Extract of take0tic.c in 3.21 release of DOS target:

/*********** Jumps ***********/

#ifdef SGMT_PTR_JMP

case TIC_C1B:

if (BOO_AFF) mic += ((short)mic[1])/2;

mic += 2;

break;

case TIC_C2B:

if (!BOO_AFF) mic += ((short)mic[1])/2;

mic += 2;

break;

case TIC_I1:

mic += ((short)*mic)/2 + 1;

break;

#else

case TIC_C1B:

if (BOO_AFF) mic = (uint16 *)((uint32)mic + (short)mic[1]);

mic += 2;

break;

case TIC_C2B:

if (!BOO_AFF) mic = mic = (uint16 *)((uint32)mic + (short)

mic[1]);

mic += 2;

break;

case TIC_I1:

mic = (uint16 *)((uint32)mic + (short)mic[0]);

mic++;

break;

#endif

/*************************/

This extract shows that the word SGMT_PTR_JMP has to be defined

(for example in tasy0def.h) before target complete re-compilation.

B- Extracts of Tasy0DOS.C

/******************************************************************

* Procedure : sys_creat_spc

* Description : Allocate common named memory

******************************************************************/

uchar sys_creat_spc(uchar slave, uchar num, char **adr,

uint32 taille)

{

char *base;

// following declaration has to be added:

uint32 i;

sys_del_spc(slave, num);

if (num > MAX_SPACE) return (BAD_RET);

// following line

// base = (char *)malloc((int)taille);

// has been replaced by :

base = (char*) _halloc(taill, sizeof(char))

if (!base) return(BAD_RET);

// following line

// memset(base, 0, (int)taille); /* filled with zero */

// has been replaced with by :

for (i=0, i<taille; i++) base[i]=0;

SPACE[num] = base;

SIZE[num] = taille;

*adr = base;

return(0);

}

 

/******************************************************************

* Procedure : sys_del_spc

* Description : link space and delete it

******************************************************************/

void sys_del_spc(uchar slave, uchar num)

{

slave = 0; /* to remove compiler warning */

if (num > MAX_SPACE) return;

if ((SPACE[num]) && (SIZE[num]))

{

// following line

// free(SPACE[num]);

// has been replaced by:

_hfree(SPACE[num]);

SPACE[num] = 0;

SIZE[num] = 0;

}

}

 

 

 

/*****************************************************************

* Procedure : sys_load_spc

* Description : Load a numbered file into a space and return space

* address

******************************************************************/

uchar sys_load_spc(uchar slave, uchar num,char **adresse)

{

FILE *fp;

char fname[40];

long size;

char *adr,*ad; // *ad has been added

struct _stat fst;

_numname(slave, num, fname);

if (_stat (fname, &fst) != 0) size = 0L;

else size = fst.st_size;

if (size == 0) return (BAD_RET);

fp = fopen(fname, "rb"); /* open file in read binary mode */

if (fp != 0)

{

if (!sys_creat_spc(slave, num, &adr, size)) /* create space */

{

// the 6 following lines have been added

ad=adr;

while (size>64000L) {

fread ( ad, (size_t)64000, 1, fp);

ad = &(ad[64000]);

size -=64000L;

}

// in following line adr has been replaced by ad

if (fread(ad, (size_t)size, 1, fp) == 1) /* fill space */

{

*adresse = adr;

fclose(fp);

return (0);

}

}

fclose(fp);

}

return (BAD_RET);

}

/*****************************************************************

* Procedure : sys_save_spc

* Description : Save a space into a numbered file

******************************************************************/

uchar sys_save_spc(uchar slave, uchar num)

{

char *adr;

uint32 size;

char fname[40];

FILE *fp;

// following line has been added (in order not to have problem

// with fopen) :

return(BAD_RET);

// But in fact you should add there your own code in order to

// make the saving, by taking ideas on what has been done with

// sys_load_spc

num %= 10; /* slave number as decimal digit */

if (sys_size_spc(slave, num, &adr, &size))

return(BAD_RET); /* link space */

_numname(slave, num, fname);

remove(fname);

fp = fopen(fname, "wb"); /* open file in write binary mode */

if (fp != 0)

{

if (fwrite(adr, (size_t)size , 1, fp) == 1) /* fill file */

{

if (!fclose(fp)) return (0);

}

fclose(fp);

remove(fname);

}

return (BAD_RET);

}

____________________________________________________________________

Copyright © 1996-2009 ICS Triplex ISaGRAF Inc. All rights reserved.